/**
 * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.nightonke.boommenusample.slice;

import com.nightonke.boommenusample.*;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.Operation;
import ohos.agp.components.Button;
import ohos.agp.components.Component;

public class MainAbilitySlice extends AbilitySlice {
    /**
     * onStart
     * @param intent
     */
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);

        listenClickEventOf(ResourceTable.Id_simple_circle_button_example);
        listenClickEventOf(ResourceTable.Id_text_inside_circle_button_example);
        listenClickEventOf(ResourceTable.Id_text_outside_circle_button_example);
        listenClickEventOf(ResourceTable.Id_ham_button_example);
        listenClickEventOf(ResourceTable.Id_square_and_piece_corner_radius_example);
        listenClickEventOf(ResourceTable.Id_boom_example);
        listenClickEventOf(ResourceTable.Id_button_place_alignment_example);
        listenClickEventOf(ResourceTable.Id_order_example);
        listenClickEventOf(ResourceTable.Id_actionbar_example);
        listenClickEventOf(ResourceTable.Id_tool_bar_example);
        listenClickEventOf(ResourceTable.Id_draggable_example);
        listenClickEventOf(ResourceTable.Id_ease_example);
        listenClickEventOf(ResourceTable.Id_listener_example);
        listenClickEventOf(ResourceTable.Id_control_example);
        listenClickEventOf(ResourceTable.Id_share_example);
        listenClickEventOf(ResourceTable.Id_list_example);
        listenClickEventOf(ResourceTable.Id_recycler_view_example);
        listenClickEventOf(ResourceTable.Id_fragment_example);
        listenClickEventOf(ResourceTable.Id_change_boom_button_example);
        listenClickEventOf(ResourceTable.Id_three_d_animation_example);
        listenClickEventOf(ResourceTable.Id_custom_position_example);
        listenClickEventOf(ResourceTable.Id_fade_views_example);
        listenClickEventOf(ResourceTable.Id_orientation_example);


        Button button1 = (Button) findComponentById(ResourceTable.Id_simple_circle_button_example);
        button1.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent secondIntent = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getContext().getBundleName())
                        .withAbilityName(SimpleCircleButtonAbility.class.getName())
                        .build();
                secondIntent.setOperation(operation);
                startAbility(secondIntent);
            }
        });

        Button button2 = (Button) findComponentById(ResourceTable.Id_text_inside_circle_button_example);
        button2.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent secondIntent = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getContext().getBundleName())
                        .withAbilityName(TextInsideCircleButtonAbility.class.getName())
                        .build();
                secondIntent.setOperation(operation);
                startAbility(secondIntent);
            }
        });

        Button button3 = (Button) findComponentById(ResourceTable.Id_text_outside_circle_button_example);
        button3.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent secondIntent = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getContext().getBundleName())
                        .withAbilityName(TextOutsideCircleButtonAbility.class.getName())
                        .build();
                secondIntent.setOperation(operation);
                startAbility(secondIntent);
            }
        });

        Button button4 = (Button) findComponentById(ResourceTable.Id_ham_button_example);
        button4.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent secondIntent = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getContext().getBundleName())
                        .withAbilityName(HamButtonAbility.class.getName())
                        .build();
                secondIntent.setOperation(operation);
                startAbility(secondIntent);
            }
        });

        Button button5 = (Button) findComponentById(ResourceTable.Id_square_and_piece_corner_radius_example);
        button5.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent secondIntent = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getContext().getBundleName())
                        .withAbilityName(SquareAndPieceCornerRadiusAbility.class.getName())
                        .build();
                secondIntent.setOperation(operation);
                startAbility(secondIntent);
            }
        });

        Button button6 = (Button) findComponentById(ResourceTable.Id_boom_example);
        button6.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent secondIntent = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getContext().getBundleName())
                        .withAbilityName(BoomExampleAbility.class.getName())
                        .build();
                secondIntent.setOperation(operation);
                startAbility(secondIntent);
            }
        });

        Button button7 = (Button) findComponentById(ResourceTable.Id_button_place_alignment_example);
        button7.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent secondIntent = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getContext().getBundleName())
                        .withAbilityName(ButtonPlaceAlignmentAbility.class.getName())
                        .build();
                secondIntent.setOperation(operation);
                startAbility(secondIntent);
            }
        });

        Button button8 = (Button) findComponentById(ResourceTable.Id_order_example);
        button8.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent secondIntent = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getContext().getBundleName())
                        .withAbilityName(OrderExampleAbility.class.getName())
                        .build();
                secondIntent.setOperation(operation);
                startAbility(secondIntent);
            }
        });

        Button button9 = (Button) findComponentById(ResourceTable.Id_actionbar_example);
        button9.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent secondIntent = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getContext().getBundleName())
                        .withAbilityName(ActionBarAbility.class.getName())
                        .build();
                secondIntent.setOperation(operation);
                startAbility(secondIntent);
            }
        });

        Button button10 = (Button) findComponentById(ResourceTable.Id_tool_bar_example);
        button10.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent secondIntent = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getContext().getBundleName())
                        .withAbilityName(ToolBarAbility.class.getName())
                        .build();
                secondIntent.setOperation(operation);
                startAbility(secondIntent);
            }
        });

        Button button11= (Button) findComponentById(ResourceTable.Id_draggable_example);
        button11.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent secondIntent = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getContext().getBundleName())
                        .withAbilityName(DraggableAbility.class.getName())
                        .build();
                secondIntent.setOperation(operation);
                startAbility(secondIntent);
            }
        });

        Button button12 = (Button) findComponentById(ResourceTable.Id_ease_example);
        button12.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent secondIntent = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getContext().getBundleName())
                        .withAbilityName(EaseAbility.class.getName())
                        .build();
                secondIntent.setOperation(operation);
                startAbility(secondIntent);
            }
        });

        Button button13 = (Button) findComponentById(ResourceTable.Id_listener_example);
        button13.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent secondIntent = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getContext().getBundleName())
                        .withAbilityName(ListenerAbility.class.getName())
                        .build();
                secondIntent.setOperation(operation);
                startAbility(secondIntent);
            }
        });

        Button button14 = (Button) findComponentById(ResourceTable.Id_control_example);
        button14.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent secondIntent = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getContext().getBundleName())
                        .withAbilityName(ControlAbility.class.getName())
                        .build();
                secondIntent.setOperation(operation);
                startAbility(secondIntent);
            }
        });

        Button button15 = (Button) findComponentById(ResourceTable.Id_share_example);
        button15.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent secondIntent = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getContext().getBundleName())
                        .withAbilityName(ShareAbility.class.getName())
                        .build();
                secondIntent.setOperation(operation);
                startAbility(secondIntent);
            }
        });

        Button button16 = (Button) findComponentById(ResourceTable.Id_list_example);
        button16.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent secondIntent = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getContext().getBundleName())
                        .withAbilityName(ListViewAbility.class.getName())
                        .build();
                secondIntent.setOperation(operation);
                startAbility(secondIntent);
            }
        });

        Button button17 = (Button) findComponentById(ResourceTable.Id_recycler_view_example);
        button17.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent secondIntent = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getContext().getBundleName())
                        .withAbilityName(RecyclerViewAbility.class.getName())
                        .build();
                secondIntent.setOperation(operation);
                startAbility(secondIntent);
            }
        });

        Button button18 = (Button) findComponentById(ResourceTable.Id_fragment_example);
        button18.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent secondIntent = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getContext().getBundleName())
                        .withAbilityName(FragmentAbility.class.getName())
                        .build();
                secondIntent.setOperation(operation);
                startAbility(secondIntent);
            }
        });

        Button button19 = (Button) findComponentById(ResourceTable.Id_change_boom_button_example);
        button19.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent secondIntent = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getContext().getBundleName())
                        .withAbilityName(ChangeBoomButtonAbility.class.getName())
                        .build();
                secondIntent.setOperation(operation);
                startAbility(secondIntent);
            }
        });

        Button button20 = (Button) findComponentById(ResourceTable.Id_three_d_animation_example);
        button20.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent secondIntent = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getContext().getBundleName())
                        .withAbilityName(ThreeDAnimationAbility.class.getName())
                        .build();
                secondIntent.setOperation(operation);
                startAbility(secondIntent);
            }
        });

        Button button21 = (Button) findComponentById(ResourceTable.Id_custom_position_example);
        button21.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent secondIntent = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getContext().getBundleName())
                        .withAbilityName(CustomPositionAbility.class.getName())
                        .build();
                secondIntent.setOperation(operation);
                startAbility(secondIntent);
            }
        });

        Button button22 = (Button) findComponentById(ResourceTable.Id_fade_views_example);
        button22.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent secondIntent = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getContext().getBundleName())
                        .withAbilityName(FadeViewsAbility.class.getName())
                        .build();
                secondIntent.setOperation(operation);
                startAbility(secondIntent);
            }
        });

        Button button23 = (Button) findComponentById(ResourceTable.Id_orientation_example);
        button23.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent secondIntent = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getContext().getBundleName())
                        .withAbilityName(OrientationAbility.class.getName())
                        .build();
                secondIntent.setOperation(operation);
                startAbility(secondIntent);
            }
        });
    }

    private void listenClickEventOf(int id) {
        findComponentById(id).setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {

            }
        });
    }

    /**
     * onActive
     */
    @Override
    public void onActive() {
        super.onActive();
    }

    /**
     * onForeground
     * @param intent
     */
    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
